from django.shortcuts import render
from django.http import HttpResponse
from host import models
# Create your views here.

def test1(request):
    return HttpResponse("HELLO")

# 数据库的添加
def add(request):

    # 方法1
        # models.Student.objects.create(name="呜啦啦",age=18)

    #方法2
        #data = {"name":"方法2","age":20}
        #models.Student.objects.create(**data)

    #方法3
        # p1 = models.Student(name="方法3",age=3)
        # p1.save()
        return HttpResponse("添加数据 Name age")

# 数据库的修改

def update(request):
    models.Student.objects.filter(name="武鹏").update(name="修改后的武鹏")
    return HttpResponse("更新数据")

# 数据库删除数据
def delete(request):
    models.Student.objects.filter(name="呜啦啦").delete()
    return HttpResponse("删除数据")